﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using Cashier.utils;
using System.Data;
using Cashier_Service;

namespace Cashier.usercontrols
{
    public class ComboBoxPaymentsSort: ComboBox
    {
        private PaymentsSortService paymentsSortService;

        public ComboBoxPaymentsSort()
        {
            paymentsSortService = new PaymentsSortService();
        }

        /// <summary>
        /// 绑定数据
        /// </summary>
        public void BindData(MainForm mainform)
        {
            try
            {
                DataTable dt = paymentsSortService.GetPaymentsSortTable(0, 0, mainform.Admin.EnterpriseNo, 0);
                List<DataItem> list = new List<DataItem>();
                list.Add(DataItem.GetDataItem("", "0"));
                list.AddRange(DataItem.GetDataItemList(dt, "name", "", "id"));
                this.DataSource = list;
                this.DisplayMember = "displayMember";
                this.ValueMember = "valueMember";
            }
            catch (Exception ex)
            {
                LogsUtil.Record(ex);
            }
        }
    }
}
